#!/usr/bin/env python
# -*- coding: utf8 -*-
# title       :
# description :
# author      :'ShenMeng'
from batchmanager.core.api import batcher


# Read me #

###--- 1. give the args of batchType and subType under @batcher(batchType, subType) ---###
# for example: 
#    @batcher('export', 'cam') 
# if you have not config subType, the subType value is 'all' : 
#    @batcher('export', 'all')  
# or  
#    @batcher('export')

@batcher('export', 'cam') 
def main(*args, **kwargs):
    """
    args:
        loggle: function to write data to disk file
            >>  loggle(data, status)
                args:
                    data: data['info'] will be set later, init value is none
                    status: 'error' or 'ok'
                    
        data: the data to write ( only to change the 'info' value )
    """
    try:
        loggle = kwargs.get('loggle')
        data = kwargs.get('data')
        ###--- 2. do your function here ---###
        from exportmanager.core import ExportManagerCam
        em = ExportManagerCam(config='deformationcar.yml')
        em.main()
    except Exception, e:
        data['info'] = str(e)
        loggle(data, 'error')
    else:
        loggle(data, 'ok')